package com.ys.shop.control;

import com.ys.shop.dao.GoodTypeDAOImp;
import com.ys.shop.factory.DaoFactoryImp;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;

public class GoodTypeServlet extends javax.servlet.http.HttpServlet {
    protected void doPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        response.setContentType("text/html;charset=UTF-8");
        response.setCharacterEncoding("utf-8");

        PrintWriter printWriter=response.getWriter();
//        printWriter.print("烤面筋");
        List list=new ArrayList();

        //获取商品类型
        try {
            GoodTypeDAOImp daoImp= new GoodTypeDAOImp();
            list=daoImp.getAll();
        } catch (Exception e) {
            e.printStackTrace();
        }
        System.out.println(list.get(1));
        request.setAttribute("alltype",list);
        //跳转
//        request.getRequestDispatcher("/Index.jsp").forward(request,response);
    }

    protected void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, IOException {
        doPost(request,response);
    }
}
